﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            var Name = textBox2.Text;
            var Age = textBox3.Text;
            var Score = textBox4.Text;

                if (!string.IsNullOrEmpty(Name))
                {
                    var sql = string.Format("insert into Students(Name,Age,Score)values('{0}','{1}','{2}')", Name, Age, Score);
                    var res = DbHelper.AddOrEdiSave(sql);

                    if (res == 1)
                    {
                        MessageBox.Show("添加成功");
                    }
                    else
                    {
                        MessageBox.Show("添加失败");
                    }
                this.DialogResult = DialogResult.OK;
                    this.Close();


                }
            }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
